/* base64.h : dgnsc base64 enc/dec
 * Copyright (C) 2009-2011 drangon <drangon.zhou@gmail.com>
 * 2011-12
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef INCLUDED_DGNSC_BASE64_H
#define INCLUDED_DGNSC_BASE64_H

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus


// padding \r\n after every linelen byte, linelen == -1 means not padding
// dst len must >= ( ( (slen + 2) / 3 * 4 + 1 ) + lineline ) / lineline * ( lineline + 2 ), 
int dgn_base64_enc( char * dst, const char * src, int slen, int linelen );
// dst len must >= (slen + 3) / 4 * 3 + 1
int dgn_base64_dec( char * dst, const char * src, int slen );

// dst len should > slen / 3 * 4
int dgn_base91_enc( char * dst, const char * src, int slen );
// dst len should > slen
int dgn_base91_dec( char * dst, const char * src, int slen );

// dst len must >= slen * 2
int dgn_base16_enc( char * dst, const char * src, int slen );
// dst len must >= slen / 2
int dgn_base16_dec( char * dst, const char * src, int slen );

#ifdef __cplusplus
}
#endif // __cplusplus

#endif // INCLUDED_DGNSC_BASE64_H

